<?php
/* [$WindsForce] (C)Hunzhiwange.COM Since 2014.07.14.
   家居公司优惠活动显示($$)*/

!defined('Q_PATH') && exit;

class Eventshow_C_Controller extends InitController{

	public function index(){
		$arrJiajucompany=$this->_oParent->_arrJiajucompany;
		$nId=intval(Q::G('id','G'));

		if(!$nId){
			$this->page404();
		}

		// 活动显示
		$arrWhere=array();
		$arrWhere['A.jiajuevent_status']=1;
		$arrWhere['A.jiajuevent_id']=$nId;
		$arrWhere['A.jiajucompany_id']=$arrJiajucompany['jiajucompany_id'];

		$arrEvent=Model::F_('jiajuevent','@A')
			->setColumns('A.jiajuevent_id,A.jiajuevent_title,A.jiajuevent_starttime,A.jiajuevent_endtime,A.jiajuevent_viewnum,A.jiajuevent_description')
			->where($arrWhere)
			->join(Q::C('DB_PREFIX').'jiajueventcontent AS B','B.jiajuevent_content','A.jiajuevent_id=B.jiajuevent_id')
			->getOne();

		if(empty($arrEvent['jiajuevent_id'])){
			$this->page404();
		}

		// 更新点击量
		Model::M_('jiajuevent')->updateWhere(array('jiajuevent_viewnum'=>$arrEvent['jiajuevent_viewnum']+1),'jiajuevent_id=?',$nId);
		$arrEvent['jiajuevent_viewnum']++;

		Core_Extend::getSeo($this,array(
			'title'=>"{$arrEvent['jiajuevent_title']}-活动信息",
			'keywords'=>"{$arrEvent['jiajuevent_title']},促销活动,优惠活动,折扣活动",
			'description'=>"{$arrEvent['jiajuevent_title']}，欢迎预订我们的服务",
		));

		$this->assign('arrEvent',$arrEvent);
		$this->display(Jiaju_Extend::getTemplate($arrJiajucompany,'eventshow'));
	}

}
